var main_timer;
$(function () {

    //倒计时


    // main_timer_function();


});

function startTimoOut() {
    set_alert('start_draw');

    $('.rightcircle').addClass('circle_right_transform');
    $('.leftcircle').addClass('circle_left_transform');

    main_timer_function();
}

function main_timer_function() {
    main_timer = setTimeout(function () {
        seconds--;
        $('.time_box').html(seconds);
        if (seconds <= 60) {
            set_alert('stop_draw');
        }

        if (seconds <= 0) {
            clearTimeout(main_timer);

            if (lottery_num.length > 0) {
                reset_number(lottery_num);
                $('.rightcircle').removeClass('circle_right_transform');
                $('.leftcircle').removeClass('circle_left_transform');
                send(JSON.stringify({'action': 'end_turn', 'content': {}}));
                lottery_num = {};

            } else {
                set_alert('tip','开奖中……',9 * 1000,false);
                // $('.time_box').html('开奖中');
                seconds = 9;
                lottery_timer = setInterval(function(){
                    var pingdata = {
                        action:'ping',
                        content:{}
                    };
                    getOpenLotteryNumber();
                    send(JSON.stringify(pingdata));
                },5000);

            }
            //摇号开奖


            //清理桌面
            $('.draw_golds_div img').addClass('bounceOutDown');
            setTimeout(function () {
                $('.draw_golds_div img').remove();
            }, 750);

        } else {
            main_timer_function();
        }
    }, 1000);
}
function clearLotteryTimer(){
    clearInterval(lottery_timer);
}


function clearTimeOut() {
    $('.draw_tip.stop_draw').hide();
    clearTimeout(main_timer);
    $('.rightcircle').removeClass('circle_right_transform');
    $('.leftcircle').removeClass('circle_left_transform');
}